// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Author: Markus Gutschke

#ifndef IJS_H__
#define IJS_H__

#include <stdint.h>
#include <sys/types.h>

struct HashMap;
struct IJS;


struct IJS *newIJS(const char *server,
                   void (*consume)(struct IJS *ijs, const char *buf, size_t sz,
                                   void *arg),
                   void *arg);
void initIJS(struct IJS *ijs, const char *server,
             void (*consume)(struct IJS *ijs, const char *buf, size_t sz,
                             void *arg), void *arg);
void destroyIJS(struct IJS *ijs);
void deleteIJS(struct IJS *ijs);

void ijsOpen(struct IJS *ijs);
void ijsClose(struct IJS *ijs);
uint32_t ijsBeginJob(struct IJS *ijs);
void ijsEndJob(struct IJS *ijs, uint32_t job);
uint32_t ijsQueryStatus(struct IJS *ijs, uint32_t job);
int ijsSetParam(struct IJS *ijs, uint32_t job, const char *param,
                const char *value, ssize_t sz);
int ijsSetParamF(struct IJS *ijs, uint32_t job, const char *param,
                 const char *fmt, ...)
  __attribute__((format(printf, 4, 5)));
const char *ijsGetParam(struct IJS *ijs, uint32_t *ret_size, uint32_t job,
                        const char *param);
struct HashMap *ijsEnumParam(struct IJS *ijs, uint32_t job, const char *param);
struct HashMap *ijsListParams(struct IJS *ijs, uint32_t job);
void ijsBeginPage(struct IJS *ijs, uint32_t job);
void ijsEndPage(struct IJS *ijs, uint32_t job);
void ijsSendData(struct IJS *ijs, uint32_t job, const char *data,
                 uint32_t sz);

#endif  // IJS_H__
